/**
 * Created by Administrator on 2018/6/1 0001.
 */
const crypto = require('crypto')
const config = require('../config')
const mongoose = require('../mongodb').connect()
const article = new mongoose.Schema({

    // 文章标题
    title: { type: String, required: true },

    // 关键字
    keyword: { type: String, required: true },

    // 描述
    descript: { type: String, required: true },

    // 标签
    tag: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Tag'}],

    // 内容
    content: { type: String, required: true },

    // 状态 1 发布 2 草稿
    state: { type: Number, default: 1 },

    // 文章公开状态 1 公开 2 私密
    publish: { type: Number, default: 1 },

    // 缩略图
    thumb: String,

    // 文章分类 1 code 2 think 3 民谣
    type: { type: Number },

    // 发布日期
    create_at: { type: Date, default: Date.now },

    // 最后修改日期
    update_at: { type: Date, default: Date.now },

    // 其他元信息
    meta: {
        views: { type: Number, default: 0 },
        likes: { type: Number, default: 0 },
        comments: { type: Number, default: 0 }
    }
})
const Article = mongoose.model('Article',article)
module.exports = Article